/// @tags: BinaryIndexedArray
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#define lowbit(x) (x & -x)

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 2e5 + 5;
int n, a[N], pos[N], maxspc[N], val[N];

inline void modify(int x, int v) {
  while (x <= n) { val[x] = std::max(val[x], v), x += lowbit(x); }
}

inline int query(int x) {
  int res = 0;
  while (x) { res = std::max(res, val[x]), x -= lowbit(x); }
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("number.in", "r", stdin);
  freopen("number.out", "w", stdout);
#endif
#endif

  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i) {
    maxspc[a[i]] = std::max(maxspc[a[i]], i - pos[a[i]]);
    pos[a[i]] = i;
  }
  memset(val, -1, sizeof(val));
  for (int i = 1; i <= n; ++i)
    maxspc[a[i]] = std::max(maxspc[a[i]], n + 1 - pos[a[i]]);
  for (int i = 1; i <= n; ++i) { modify(maxspc[a[i]], a[i]); }
  for (int i = 1; i <= n; ++i) { printf("%d ", query(i)); }
  return 0;
}